/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ac.pbp.core.util;

import javax.servlet.http.HttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

/**
 *
 * @author Kim
 */
public class ViewHelper {
    public static final ModelAndView redirectTo(String url) {
        return new ModelAndView(new RedirectView(url, true));
    }

    public static final ModelAndView nextView(HttpServletRequest request, String url, String paramName, Object param) {
        ModelAndView modelAndView = new ModelAndView(url);
        modelAndView.addObject(paramName, param);
        modelAndView.addObject("error", request.getParameter("error"));

        return modelAndView;
    }

    public static final ModelAndView newInstance(String url, String param, Object object) {
        ModelAndView view = new ModelAndView(url);
        view.addObject(param, object);
        return view;
    }
}
